
export function setData(dateArr) {

	const getNewDate = (time) => {
		let date = new Date(time).getTime() + 1000 * 60 * 60 * 24;
		let Y = new Date(date).getFullYear() + '-';
		let M = (new Date(date).getMonth() + 1 < 10 ? '0' + (new Date(date).getMonth() + 1) : new Date(date)
			.getMonth() + 1) + '-';
		let D = new Date(date).getDate() < 10 ? '0' + new Date(date).getDate() : new Date(date).getDate();
		return Y + M + D;
	};

	//　新日期数组
	let newDateArr = [];
	newDateArr.push(dateArr[0], dateArr[dateArr.length - 1]);
	let startDate = newDateArr[newDateArr.length - 2].date;
	let endDate = newDateArr[newDateArr.length - 1].date;
	let startStamp = new Date(startDate).getTime();
	let endStamp = new Date(endDate).getTime();
	let diffCounts = Math.abs(startStamp - endStamp) / 1000 / 60 / 60 / 24;
	// 得出倒数第二天和倒数第一天的相差天数，依次递减，直到相差１天，表示是相邻的两天
	for (let index = diffCounts; index > 1; index--) {
		//　根据时间戳得出应该往后加的日期
		getNewDate(newDateArr[newDateArr.length - 2].date);
		//　把新的日期从倒数第二个位置追加到新日期数组
		newDateArr.splice(newDateArr.length - 1, 0, {
			date: getNewDate(newDateArr[newDateArr.length - 2].date),
			count: 0,
		});
	}
	newDateArr.forEach((newItem) => {
		dateArr.forEach((oldItem) => {
			if (newItem.date === oldItem.date) {
				newItem.count = oldItem.count;
			}
		});
	});
	// 　　　 console.log('原来的缺失日期',dateArr);
	//       console.log('补全后的日期',newDateArr);
	return newDateArr

}